package logic

import (
	"context"

	"tianji-network/service/satellite/rpc/internal/svc"
	"tianji-network/service/satellite/rpc/model"
	"tianji-network/service/satellite/rpc/satellite"

	"github.com/zeromicro/go-zero/core/logx"
)

type GetLogic struct {
	ctx    context.Context
	svcCtx *svc.ServiceContext
	logx.Logger
}

func NewGetLogic(ctx context.Context, svcCtx *svc.ServiceContext) *GetLogic {
	return &GetLogic{
		ctx:    ctx,
		svcCtx: svcCtx,
		Logger: logx.WithContext(ctx),
	}
}

func (l *GetLogic) Get(in *satellite.IdReq) (*satellite.SatelliteOne, error) {
	satelliteModel, err := l.svcCtx.Model.FindOne(l.ctx, in.Id)
	if err != nil {
		return nil, err
	}
	return model.ModelConvertToProto(satelliteModel), nil
}
